package moxl.xpath.functions;

import moxl.xpath.XPathContext;
import moxl.xpath.parser.states.step.Function;
import moxl.xpath.parser.types.XPathEvaluationException;
import moxl.xpath.parser.types.XPathNumberValue;
import moxl.xpath.parser.types.AbstractXPathValue;

public class LastFunction implements Function
{
	public AbstractXPathValue execute(XPathContext ctx, AbstractXPathValue... args) throws XPathEvaluationException
	{
		if (args.length != 0)
		{
			throw new XPathFunctionIllegalArgumentCountException("This function (" + this.getName() + ") takes no arguments");
		}
		return new XPathNumberValue(ctx.getSize());
	}

	public String getName()
	{
		return "last";
	}

}
